<?php

namespace App\Admin\Controllers;

use App\Models\ActiveCode;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;

class ActiveCodeController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(ActiveCode::with(['user']), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('user_id');
            $grid->column('user.email', '邮箱');
            $grid->column('user.mobile', '手机');
            $grid->column('code');
            $grid->column('created_at');

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
                $filter->equal('user_id');
                $filter->equal('user.email', '邮箱');
                $filter->equal('user.mobile', '手机');
            });
            $grid->disableBatchDelete();
            $grid->disableRowSelector();
            $grid->disableActions();
            $grid->disableCreateButton();
        });
    }
}
